package com.jiang.专题.数组.Q283;

/**
 * @author Jiang
 * @version 1.0
 * @date 2025/03/16 22:37
 */
class Solution {
    public void moveZeroes(int[] nums) {
        int i = 0;
        int len = nums.length;
        for (; i < len; i++) {
            if (nums[i] == 0)
                break;
        }

        int j = i + 1;
        for (; j < len; j++) {
            if (nums[j] != 0)
                break;
        }

        while (j < len) {
            nums[i++] = nums[j];
            nums[j++] = 0;
            for (; i < len; i++) {
                if (nums[i] == 0)
                    break;
            }
            for (; j < len; j++) {
                if (nums[j] != 0)
                    break;
            }
        }
    }
}
